
import { BaseEntity, Column, JoinTable, Entity, JoinColumn, ManyToMany, ManyToOne, OneToMany, OneToOne, PrimaryGeneratedColumn } from "typeorm";
import { MenuEntity } from "./menu.entity";
import { UsersEntity } from "./user.entity";

@Entity({ name: 'role' })
export class RoleEntity extends BaseEntity {
    @PrimaryGeneratedColumn()
    id: number;
    
    @Column({ type: 'varchar', length: 50 })
    rname: string;


    @OneToMany(
        () => UsersEntity,
        role => role.role
    )
    @JoinColumn()
    userEntity: UsersEntity[];

    @ManyToMany(
        () => MenuEntity,
        m => m.role
    )
    @JoinTable()
    menu: MenuEntity[];


}
